<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <style>
    #box {
      width: 300px;
      height: 225px;
      border: 1px solid #000;
    }
  </style>
</head>

<body>
  <div id="box" ondrop="box(event)" ondragover="allowDrop(event)">
    <img id="img" src="../images/1.webp" draggable="true" ondragstart="drag(event)" width="300">
  </div>

  <div id="box" ondrop="box(event)" ondragover="allowDrop(event)"></div>


  <script>
    const box = (e) => {
      console.log(e);
      e.preventDefault()
      let data = e.dataTransfer.getData('text')
      console.log(data);
      e.target.appendChild(document.getElementById(data));
    }

    const drag = (e) => {
      console.log(e);
      e.dataTransfer.setData('text', e.target.id)
    }

    const allowDrop = (e) => {
      // console.log(e);
      e.preventDefault()
    }
  </script>
</body>

</html>